// Avoid `console` errors in browsers that lack a console.
(function () {
    var method;
    var noop = function () {
    };
    var methods = [
        'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
        'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
        'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
        'timeStamp', 'trace', 'warn'
    ];
    var length = methods.length;
    var console = (window.console = window.console || {});

    while (length--) {
        method = methods[length];

        // Only stub undefined methods.
        if (!console[method]) {
            console[method] = noop;
        }
    }
}());

// Place any jQuery/helper plugins in here.


// Prevent console.log from generating errors in IE for the purposes of the demo
if (!window.console) console = { log: function () {
} };

// The actual plugin
$('.home .single-page-nav').singlePageNav({
    //offset: $('.single-page-nav').outerHeight(),
    filter: ':not(.external)',
    updateHash: true,
    beforeStart: function () {
        console.log('begin scrolling');
    },
    onComplete: function () {
        console.log('done scrolling');
    }
});


// Custom scripts


$(document).ready(function () {


    //features
    $(".featuresList div").click(function () {
        var fdiva = $(this);
        var get_rel = fdiva.children().attr('rel');
        var popupContent = $('.featuresCircle .popupContent');

        $(".pops").fadeOut();
        if ($(this).hasClass('active')) {
            $(".featuresList div").removeClass('active');
            fdiva.removeClass('active');
            $(".pops").fadeOut();
        }
        else if ($(".featuresList div").hasClass('active')) {
            $(".popupContent").hide();
            //$(".pops").hide();
            $(fdiva).addClass('active');
            $("#" + get_rel).fadeIn(100);
            $("#" + get_rel).children().fadeIn();
        }
        else {
            $(fdiva).addClass('active');
            $("#" + get_rel).fadeIn(100);
        }
    });
    $(".pops").mouseup(function () {
        return false;
    });
    $(document).mouseup(function () {
        $(".featuresList div").removeClass('active');
        $(".pops").fadeOut();
    });

    //down arrow
    $(".homeSlide").each(function () {
        $(this).append('<a class="nextSlide"></a>');
    });
    $(".nextSlide").click(function () {
        var next;
        next = $(this).parent().next()
        $("html, body").animate({scrollTop: next.offset().top}, 2000);
    });


});

$(window).bind('scroll', function () {
    if ($(window).scrollTop() > 100) {
        $('.ha-header').removeClass('ha-header-shrink').addClass('ha-header-show');
        $('.elem10').animate({scrollTop: 0}, 'slow');
    }
    else {
        $('.ha-header').removeClass('ha-header-show').addClass('ha-header-shrink');
    }


});


// HomeSlide *****//

function UpdateTableHeaders() {
    $(".homeSlide").each(function () {

        var el = $(this),
            offset = el.offset(),
            scrollTop = $(window).scrollTop() + 540,
            scrollTop2 = $(window).scrollTop(),
            floatingHeader = $(".floatingHeader", this)

        if ((scrollTop > offset.top) && (scrollTop < offset.top + el.height())) {
            el.addClass("selected");

        } else {
            //el.removeClass("selected");
        }
        ;


        if ((scrollTop2 > offset.top) && (scrollTop2 < offset.top + el.height())) {
            el.addClass("selected2");

        } else {
            //el.removeClass("selected2");
        }
        ;


    });
}

// DOM Ready
$(function () {



    //
    $(window)
        .scroll(UpdateTableHeaders)
        .trigger("scroll");

});


//
$(function () {
    $(".move").draggable();
});


// jQuery width
function jqUpdateSize() {
    // Get the dimensions of the viewport
    var width = $(window).width();
    var height = $(window).height();

    if (width <= 640) {
        //$('.ha-header').removeClass('ha-header');
        $('.ha-header').addClass('ha-header-show');
    }

    else {
        //$('.ha-header').addClass('ha-header');
        $('.ha-header').removeClass('ha-header-show');

    }


    if (width <= 767) {
        $('.contctph').insertAfter('.navbar-brand');
        $('.secNav').insertAfter('.single-page-nav');
    }

    else {
        $('.contctph').insertAfter('.single-page-nav');
        $('.secNav').insertBefore('.single-page-nav');
    }


};
$(document).ready(jqUpdateSize);    // When the page first loads
$(window).resize(jqUpdateSize);     // When the browser changes size


//elasticstack section Blog

new ElastiStack(document.getElementById('elasticstack'));
new ElastiStack(document.getElementById('elasticstack2'));
new ElastiStack(document.getElementById('elasticstack3'));
new ElastiStack(document.getElementById('elasticstack4'));
new ElastiStack(document.getElementById('elasticstack5'));
new ElastiStack(document.getElementById('elasticstack6'));










